
		**********************************************************
		** File: Figure_1.do									**
		** Paper: Human Trafficking Indicators: A New Dataset	**
		** Author: Richard Frank								**
		** Date: July 11, 2021									**
		** Task: Creating Figure 1								**
 		**********************************************************

 

	clear
	version 16.1
	set seed 1234
	set scheme lean1
	graph set window fontface "Times New Roman"

	use "HTI_v1.dta"
	
	** SUMMARY STATISTICS FOR 2001-2016

	drop if ccode==-11
	drop if ccode==-22
	drop if ccode==-33

	sort year
	by year: egen totalcountries=count(ccode)
	label var totalcountries "Total # countries in given year"

 

	**DICHOTOMIZING STD **

	gen sourcedich=.
	replace sourcedich=1 if source>0
	label var sourcedich "Source state (dichotomous)"

	gen destdich=.
	replace destdich=1 if destination>0
	label var destdich "Destination state (dichotomous)"

	gen transitdich=.
	replace transitdich=1 if transit>0
	label var transitdich "Transit state (dichotomous)"

	gen internaldich=.
	replace internaldich=1 if internal==1
	label var internaldich "Internal state (dichotomous)"

	**WHICH WAS FIRST **
	gen sourcefirstdi=.
	replace sourcefirstdi=1 if source==1
	label var sourcefirstdi "First mentioned source"

	gen destfirstdi=.
	replace destfirstdi =1 if destination==1
	label var destfirstdi "First mentioned destination"

	gen transitfirstdi=.
	replace transitfirstdi =1 if transit==1
	label var transitfirstdi "First mentioned transit"


	**TOTAL IN A YEAR **

	sort year
	by year: egen sourcetot=count(sourcedich)
	label var sourcetot "Total # source states in a year"

	sort year
	by year: egen sourcefirsttot=count(sourcefirstdi)
	label var sourcefirsttot "Total # 1st source states in a year"

	sort year
	by year: egen desttot=count(destdich)
	label var desttot "Total # destination states in a year"

	sort year
	by year: egen destfirsttot=count(destfirstdi)
	label var destfirsttot "Total # 1st source states in a year"

	sort year
	by year: egen transittot=count(transitdich)
	label var transittot "Total # transit states in a year"

	sort year
	by year: egen transitfirsttot=count(transitfirstdi)
	label var transitfirsttot "Total # 1st transit states in a year"

	by year: egen internaltot=count(internaldich)
	label var internaltot "Total # internal states in a year"


	** PERCENTAGE IN A YEAR **


	gen sourcepct=sourcetot/totalcountries
	label var sourcepct "% countries in a year that are source"

	gen destpct=desttot/totalcountries
	label var destpct "% countries in a year that are destination"

	gen transitpct=transittot/totalcountries
	label var transitpct "% countries in a year that are transit"

	gen internalpct=internaltot/totalcountries
	label var internalpct "% countries in a year that are internal"


	***OVERALL FIRST COUNTRIES **


	gen sourcepct1=sourcefirsttot/totalcountries
	label var sourcepct "% countries in a year that are source"

	gen destpct1=destfirsttot/totalcountries
	label var destpct "% countries in a year that are destination"

	gen transitpct1= transitfirsttot/totalcountries
	label var transitpct "% countries transit"


********************************************************************************
**
** LOOKING AT PARTICULAR TYPES OF TRAFFICKING **
**
********************************************************************************



******************
***Prostitution **
******************

**DICHOTOMIZING **
	gen psourcedich=.
	replace psourcedich=1 if psource==1
	label var psourcedich "Prostitution Source (dich)"

	gen ptransitdich=.
	replace ptransitdich =1 if ptransit==1
	label var ptransitdich "Prostitution Transit (dich)"

	gen pdestdich=.
	replace pdestdich =1 if pdest==1	
	label var pdestdich "Prostitution Destination (dich)"

	gen pinternaldich=.
	replace pinternaldich =1 if pinternal==1
	label var pinternaldich "Prostitution Internal (dich)"

**TOTAL IN A YEAR **
	sort year
	by year: egen psourcetot=count(psourcedich)
	label var psourcetot "Total # Prostitution source states in a year"

	sort year
	by year: egen pdesttot=count(pdestdich)
	label var pdesttot "Total # Prostitution destination states in a year"

	sort year
	by year: egen pinternaltot=count(pinternaldich)
	label var pinternaltot "Total # Prostitution internal states in a year"

	sort year
	by year: egen ptransittot=count(ptransitdich)
	label var psourcetot "Total # Prostitution transit states in a year"

**PERCENTAGE **

	gen psourcepct=psourcetot/totalcountries
	label var psourcepct "Source"

	gen pdestpct=pdesttot/totalcountries
	label var pdestpct "Destination"

	gen ptransitpct=ptransittot/totalcountries
	label var ptransitpct "Transit"

	gen pinternalpct=pinternaltot/totalcountries
	label var pinternalpct "Internal"

	twoway (line psourcepct year, sort) (line pdestpct year, sort) ///
	 (line ptransitpct year, sort)(line pinternalpct year, sort), ///
	 ytitle(% of countries in sample) title(Forced Prostitution) legend(cols(2) pos(6))

	graph save prostitution.gph, replace


							***********
							***LABOR **
							***********

**DICHOTOMIZING **

	gen lsourcedich=.
	replace lsourcedich=1 if lsource==1
	label var lsourcedich "Labor Source (dich)"

	gen ltransitdich=.
	replace ltransitdich =1 if ltransit==1
	label var ltransitdich "Labor Transit (dich)"

	gen ldestdich=.
	replace ldestdich =1 if ldest==1	
	label var ldestdich "Labor Destination (dich)"

	gen linternaldich=.
	replace linternaldich =1 if linternal==1
	label var linternaldich "Labor Internal (dich)"

**TOTAL IN A YEAR **

	sort year
	by year: egen lsourcetot=count(lsourcedich)
	label var lsourcetot "Total # Labor source states in a year"

	sort year
	by year: egen ldesttot=count(ldestdich)
	label var ldesttot "Total # Labor destination states in a year"

	sort year
	by year: egen linternaltot=count(linternaldich)
	label var linternaltot "Total # Labor internal states in a year"

	sort year
	by year: egen ltransittot=count(ltransitdich)
	label var lsourcetot "Total # Labor transit states in a year"

**PERCENTAGE **

	gen lsourcepct=lsourcetot/totalcountries
	label var lsourcepct "Source"

	gen ldestpct=ldesttot/totalcountries
	label var ldestpct "Destination"

	gen ltransitpct=ltransittot/totalcountries
	label var ltransitpct "Transit"

	gen linternalpct=linternaltot/totalcountries
	label var linternalpct "Internal"

	twoway (line lsourcepct year, sort) (line ldestpct year, sort) ///
	 (line ltransitpct year, sort)(line linternalpct year, sort), ///
	 ytitle(% of countries in sample) title(Forced Labor) legend(cols(2) pos(6))
	 
	graph save labor.gph, replace

	graph combine prostitution.gph labor.gph, ycommon

 
